package com.hy.mydesktop.server.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;



import com.extjs.gxt.ui.client.data.BaseModel;
import com.hy.mydesktop.server.dao.UserDao;
import com.hy.mydesktop.shared.persistence.domain.User;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtComponentControllerMetaModel;

/**
 * 
 * 
 * <ul>
 * <li>开发作者：花宏宇</li>
 * <li>设计日期：2011-9-10；时间：上午08:57:42</li>
 * <li>类型名称：UserService</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
@Component
public class UserService {
	
	public UserDao<User> getUserDao() {
		return userDao;
	}

	@Resource
	public void setUserDao(UserDao<User> userDao) {
		this.userDao = userDao;
	}

	
	public ComponentControllerMetaModelService getComponentControllerMetaModelService() {
		return componentControllerMetaModelService;
	}
	
	@Resource
	public void setComponentControllerMetaModelService(
			ComponentControllerMetaModelService componentControllerMetaModelService) {
		this.componentControllerMetaModelService = componentControllerMetaModelService;
	}

	private ComponentControllerMetaModelService componentControllerMetaModelService;
	private UserDao<User> userDao;

	public Boolean addUser(User user) {
		return userDao.persist(user);
	}
	
	public Boolean deleteUser(String id) {
		return userDao.remove(id);
	}
	
	public Boolean updateUser() {
		return null;
	}
	
	public User findUserById(String id) {
		return userDao.findByIdentifier(id);
	}
	
	public List<User> findUser(int first,int max) {
		return userDao.find(first, max);
	}
	
	/**
	 * 
	 * mmmmmmmm@return
	 */
	public BaseModel loginSystem() {
		User user = userDao.findUniqueResult("");
		if (user==null) {
			
		} else {
			List<GxtComponentControllerMetaModel> list =componentControllerMetaModelService.findComponentControllerMetaModeByUserId(user.getId());
		}
		return null;
	}
}
